
const cp = require("child_process");
const fs = require("fs");
const path = require("path");

let ffmpegs = `
-formats            show available formats
-muxers             show available muxers
-demuxers           show available demuxers
-devices            show available devices
-codecs             show available codecs
-decoders           show available decoders
-encoders           show available encoders
-bsfs               show available bit stream filters
-protocols          show available protocols
-filters            show available filters
-pix_fmts           show available pixel formats
-layouts            show standard channel layouts
-sample_fmts        show available audio sample formats
-colors             show available color names
`
// 生成内容
ffmpegs.split(/[\r\n]/)
    .filter(d => d)
    .map(d => d.trim())
    .forEach(line => {
        let [arg, ...other] = line.split("  ");
        // console.log('line',arg);
        let command = "ffmpeg " + arg;
        let outFile = path.join(__dirname, "ffmpeg", "ffmpeg" + arg + ".txt");
        exec2file(command, outFile);
    });

function exec2file(command, outFile) {
    cp.exec(command, function (err, stdout, stderr) {
        if (err) {
            console.log(command + "err :", err);
        } else {
            console.log("dd", stdout);
            fs.writeFile(outFile, stdout, (err, data) => {
                if (err) {
                    console.log(command + "write err :", err);
                } else {
                    console.log(command + "ok");
                }
            })
        }
    });
}




